VERSION 5.00
Begin VB.Form Reports_Form 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   BorderStyle     =   0  'None
   ClientHeight    =   9000
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   12000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   9000
   ScaleWidth      =   12000
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   WindowState     =   2  'Maximized
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "Courier New"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1995
      Left            =   1020
      MultiLine       =   -1  'True
      TabIndex        =   2
      Top             =   1200
      Width           =   7995
   End
   Begin VB.CommandButton Cancel_Button 
      BackColor       =   &H008080FF&
      Caption         =   "Cancel"
      BeginProperty Font 
         Name            =   "Arial Narrow"
         Size            =   20.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   9600
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   7020
      Width           =   1935
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Condoms Given Out (last 3 months)"
      BeginProperty Font 
         Name            =   "Arial Narrow"
         Size            =   15.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   1080
      TabIndex        =   1
      Top             =   720
      Width           =   4335
   End
End
Attribute VB_Name = "Reports_Form"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Cancel_Button_Click()
   VCTStageForm.Show
   Unload Me
End Sub

Private Sub Form_Load()

   Dim m1s, m2s, m3s As String
   Dim m1i, m2i, m3i As Integer
   Dim y1i, y2i, y3i As Integer
   'Dim curyear As Integer
   Dim m1ClinCond, m1CounCond As Long
   Dim m2ClinCond, m2CounCond As Long
   Dim m3ClinCond, m3CounCond As Long
   
   m1i = Month(Date) 'current month
   y1i = Year(Date)
   
   If m1i = 1 Then 'january
      m2i = 12
      y2i = y1i - 1
   Else 'same year
      m2i = m1i - 1
      y2i = y1i
   End If
   
   If m2i = 1 Then 'january
      m3i = 12
      y3i = y2i - 1
   Else 'same year
      m3i = m2i - 1
      y3i = y2i
   End If
   
   
   m3s = MonthName(m3i, True)
   m2s = MonthName(m2i, True)
   m1s = MonthName(m1i, True)
   
   'Current month
   CnUser.Open ConnectString
'   Cmd.CommandText = "SELECT SUM(COUNCOND), SUM(CLINCOND)" _
'                  & " FROM   client" _
'                  & " WHERE MONTH(VDATE) = '" & m1s & "'" _
'                  & " AND YEAR(VDATE) = '" & y1i & "'"
   Cmd.CommandText = "SELECT SUM(COUNCOND), SUM(CLINCOND)" _
                  & " FROM   client" _
                  & " WHERE SUBSTRING(VDATE,4,3) = '" & m1s & "'" _
                  & " AND SUBSTRING(VDATE,8,4) = '" & y1i & "'"
   Cmd.CommandType = adCmdText
   Cmd.ActiveConnection = CnUser
   RsUser.Open Cmd, , adOpenStatic
   If IsNull(RsUser(0)) Then
      m1CounCond = 0
   Else
      m1CounCond = RsUser(0)
   End If
   If IsNull(RsUser(1)) Then
      m1ClinCond = 0
   Else
      m1ClinCond = RsUser(1)
   End If
   RsUser.Close
   CnUser.Close
   
   'last month
   CnUser.Open ConnectString
   Cmd.CommandText = "SELECT SUM(COUNCOND), SUM(CLINCOND)" _
                  & " FROM   client" _
                  & " WHERE SUBSTRING(VDATE,4,3) = '" & m2s & "'" _
                  & " AND SUBSTRING(VDATE,8,4) = '" & y2i & "'"
   Cmd.CommandType = adCmdText
   Cmd.ActiveConnection = CnUser
   RsUser.Open Cmd, , adOpenStatic
   If IsNull(RsUser(0)) Then
      m2CounCond = 0
   Else
      m2CounCond = RsUser(0)
   End If
   If IsNull(RsUser(1)) Then
      m2ClinCond = 0
   Else
      m2ClinCond = RsUser(1)
   End If
   RsUser.Close
   CnUser.Close

   'two months ago
   CnUser.Open ConnectString
   Cmd.CommandText = "SELECT  SUM(COUNCOND), SUM(CLINCOND)" _
                  & " FROM   client" _
                  & " WHERE SUBSTRING(VDATE,4,3) = '" & m3s & "'" _
                  & " AND SUBSTRING(VDATE,8,4) = '" & y3i & "'"
   Cmd.CommandType = adCmdText
   Cmd.ActiveConnection = CnUser
   RsUser.Open Cmd, , adOpenStatic
   If IsNull(RsUser(0)) Then
      m3CounCond = 0
   Else
      m3CounCond = RsUser(0)
   End If
   If IsNull(RsUser(1)) Then
      m3ClinCond = 0
   Else
      m3ClinCond = RsUser(1)
   End If
   RsUser.Close
   CnUser.Close
   
   Text1.Text = "By          Clinical Officer     Counselor     " & vbCr & vbLf
   Text1.Text = Text1.Text & m1s & " " & y1i & "          " & m1ClinCond & Space(18 - Len(m1ClinCond)) & m1CounCond & vbCr & vbLf
   Text1.Text = Text1.Text & m2s & " " & y2i & "          " & m2ClinCond & Space(18 - Len(m2ClinCond)) & m2CounCond & vbCr & vbLf
   Text1.Text = Text1.Text & m3s & " " & y3i & "          " & m3ClinCond & Space(18 - Len(m3ClinCond)) & m3CounCond & vbCr & vbLf
   
End Sub
